var phoneReg=/^1[345789][0-9]{9}$/;

phone.onkeyup = function(){
    var phoneValue=phone.value;

    var phoneerror = document.getElementById("phoneerror");
    if(!phoneReg.test(phoneValue)){
        phoneerror.innerHTML = "手机号码有误!";
        isPhoneRight = false;
    }else{
        phoneerror.innerHTML = "<img src='images/dui.png' style='width:14px'/>";
        isPhoneRight = true;
    }
    checkAll();
};
phone.onblur = function(){
    $.get("http://test.hfjava.com/shop/userphone?phone="+phone.value,{},
        function (data){
            if(data=="true"){
                alert("您输入的电话号码不存在");
                submitBtn.setAttribute("disabled","disabled");
                submitBtn.style.background="#8e8e8e;";
                submitBtn.style.color="#333";
            }
        })
};

function checkAll(){
    var isRight = isPhoneRight;
    if(isRight) {
        submitBtn.removeAttribute("disabled");
        submitBtn.style.background="red";
        submitBtn.style.color="#fff";
    }else{
        submitBtn.setAttribute("disabled","disabled");

    }
}

$("#submitBtn").click(function () {
    localStorage.setItem("phone",phone.value);
});